12. Binary Search If ( value == middle element ) value is found else if ( value < middle element ) search left-half of list with the same method else search right-half of list with the same method http://ecomputernotes.com
13. Case 1: val == a[mid] val = 10 low = 0, high = 8 5 7 9 10 13 17 19 1 27 1 2 3 4 5 6 7 0 8 a: low high Binary Search mid mid = (0 + 8) / 2 = 4 10 http://ecomputernotes.com
14. Case 2: val > a[mid] val = 19 low = 0, high = 8 mid = (0 + 8) / 2 = 4 Binary Search -- Example 2 5 7 9 10 1 13 17 19 27 1 2 3 4 5 6 7 0 8 a: mid low high new low new low = mid+1 = 5 13 17 19 27 http://ecomputernotes.com
15. Case 3: val < a[mid] val = 7 low = 0, high = 8 mid = (0 + 8) / 2 = 4 Binary Search -- Example 3 10 13 17 19 5 7 9 1 27 1 2 3 4 5 6 7 0 8 a: mid low high new high new high = mid-1 = 3 5 7 9 1 http://ecomputernotes.com
40. Skip Lists with Quad Nodes 56 64 78 31 34 44 12 23 26 31 64 31 34 23 S 0 S 1 S 2 S 3
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51. Finding the hash function int hashCode( char* s ) { int i, sum; sum = 0; for(i=0; i < strlen(s); i++ ) sum = sum + s[i]; // ascii value return sum % TABLESIZE; }